<?$this->_extends("_layouts/main_layout");?>

<?$this->_block("contents");?>

<script type="text/javascript">
<!--
function check(){
		return confirm('确定删除该留言信息吗？');
	
}

function domessage(flag) {
    var ids = $('#waitforcheck :checked').map(function() {
	return this.value;
    }).get();
    if (!$('#waitforcheck :checked').length) {
        alert('请选择留言信息!');
        return;
    }
    if(flag==0){
	if (!confirm('确定要屏蔽选中的留言吗？')) return;	
    }else{
	if (!confirm('确定要开启选中的留言吗？')) return;	
    }
	
	var messageid= "";
	$.each(ids, function(i,id) {
		
		 messageid+=id;if (ids.length-1>i) messageid+= ",";
		
	});
	
		$.ajax({
			type : "post",
			method : "post",
			dataType : "json",
			data:{"messageid":messageid,"flag":flag},
			url : "<?=url("/domessage")?>",
			success : function(data) {
				if(data==0){
					alert("选中的留言已屏蔽！");
					
				}else{
					alert("选中的留言已开启！");
					
				}
				location='<?php echo url('');?>';
			}
		 });
		

}

//-->
</script>
<fieldset id="query_form_f" class="query_form">
	<legend><span onclick="show_fld();" style="color:blue;cursor:pointer;">过滤条件</span></legend>
	<div id="filter_show">
	<form action="" method="get" id="form1" name="form1" style="margin-top:0">
		<table class="searchv_table" cellpadding="0" cellspacing="2" style="text-align: center;" >
		       <tr>
				<td style="text-align:left">提问内容：<input type="text" style="width:137px;" id="keywords" name="keywords" value="<?php if(isset($keywords)){echo $keywords;}?>"/></td>
																						  	
						<td width="100px;" colspan="3" style="text-align:left;">
				    <nobr>
				    <input type="submit" class="btn" value="查询"  style="margin-left:0px;width:80px;"/>
				    <input type="reset" class="btn" value="重置" onclick="javascript:location='<?php echo url('');?>';" style="width: 80px;"/>
				    
				    </nobr>
				</td>
			</tr>
		</table>
  </form>
</div>
</fieldset>

<table class="list_table" width="100%" cellpadding="0" cellspacing="0">
	
	<tr>
		<th >全选<input type="checkbox" onclick="checkall.call(this,'waitforcheck','ids')" /></th>
		<th width="">提问人</th>
		<th width="">提问人ip</th>		
		<th width="">电子邮箱</th>
		<th width="">联系电话</th>
		<th width="">提问内容</th>
		<th width="">提问时间</th>
		<th width="">回复人</th>
		<th width="">回复内容</th>
		<th width="">回复时间</th>
		<th width="">是否显示</th>
        <?php if (hp('message.3')||hp('message.4')) {?>
		<th width="" >操作</th>
        <?php }?>
	</tr>
<tbody id="waitforcheck">	
<?foreach ($list as $i=>$row) {?>
	<tr>
		<td><input type="checkbox" name="ids[]" value="<?=$row['id']?>" /></td>
		<td><?=$row['asker']?></td>
		<td><?=$row['ip']?></td>
		<td><?=$row['email']?></td>
		<td><?=$row['tel']?></td>
		<td><?=strlen($row['question'])>60?substr($row['question'], 0, 60).'...':$row['question'] ?></td>
		<td><?=empty($row['q_time'])?"-":date("Y-m-d H:i",$row['q_time']) ?></td>
		<td><?=$row->admin->name?></td>
		<td><?=strlen($row['answer'])>60?substr($row['answer'], 0, 60).'...':$row['answer']?></td>
		<td><?=empty($row['a_time'])?"-":date("Y-m-d H:i",$row['a_time']) ?></td>
		<td><?=$row['show_flag']?'是':'否' ?></td>
		
        <?php if (hp('message.3')||hp('message.4')) {?>
    <td><?php if (hp('message.3')) {?><a href="<?=url('/edit', array('id'=>$row['id']))?>" style="color:blue" title="回复">[回复]</a><?php }?> 
      	<?php if (hp('message.4')) {?><a href="<?=url('/delete', array('id'=>$row['id']))?>" onclick="return check()" style="color:blue" title="删除">[删除]</a><?php }?>
      	<a href="<?=url('/view', array('id'=>$row['id']))?>" style="color:blue" title="查看">[查看]</a>
    </td>
        <?php }?>		
	</tr>
	
<? }?>
</tbody>
</table><br>
<?php if (hp('message.3')) {?>
<input type="button" class="btn" value="屏蔽" onclick="domessage(0);" />
<input type="button" class="btn" value="开启" onclick="domessage(1);" />
<?php }?>
<?$this->_control("pagination", "", array('pagination'=>$pager));?>


<?$this->_endblock();?>
